<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<header th:replace="inc/header"></header>

<body th:with="menu='intoPrison'">
<nav th:replace="inc/nav"></nav>
<style>
	.treeview ul.list-group,.treeview0 ul.list-group{
		position:absolute;
		left: 80px;
    	top: -5px;
	}
	.treeview ul li.list-group-item,.treeview0 ul li.list-group-item{
		/* height:30px; */
		line-height:30px;
		padding: 0 15px;
		cursor:pointer;
	}
	.iscard .card-list a{
		line-height:2;
	}
	.search-title .dropdown-menu .divider{
		margin:0;
	}
</style>
<div class="container-fluid">
  <div class="row">
    <div th:replace="inc/sidebar"></div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <h1 class="page-header">
        民警进监记录查询
      </h1>
      <div class=" col-md-12 search-title">
      	<div class="col-md-11">
      		<div class="col-md-2" style="display:none;">
      			<span class="font-weight">监所编号：</span><span class="shift-jsbh" th:text="${jsbh}"></span>
      		</div>
      		<div class="col-md-4">
 				<span class="font-weight">民警姓名:</span>
				<input class="policeName" type="text" />
 			</div>
      		<div class="col-md-4">
      			<span class="font-weight">开始时间：</span><input type="text" name="datetime" class="ui_timepicker shift-start-time" value="">
      		</div>
      		<div class="col-md-4">
      			<span class="font-weight">结束时间：</span><input type="text" name="datetime" class="ui_timepicker shift-end-time" value="">
      		</div>
      	</div>
      
      	<div class="col-md-1">
          <a class="btn btn-primary btn-sm" id="btnSearch">查询</a>
        </div>
      </div>
      <table class="table table-striped searchList">
        <thead>
        <tr>
          <th>监室号</th>
          <th>民警姓名</th>
          <!-- <th>是否刷卡</th> -->
          <th>进监时间</th>
        </tr>
        </thead>
        <tbody>
        
        </tbody>
      </table>
    </div>
  </div>
</div>



<div th:replace="inc/footer"></div>
<div th:replace="inc/footer1"></div>


<script th:inline="javascript">
$(function () {
    $(".ui_timepicker").datetimepicker({
        showSecond: true,
        timeFormat: 'hh:mm:ss',
        stepHour: 1,
        stepMinute: 1,
        stepSecond: 1
    });
	function nowDate(){
		var myDate = new Date();
		var y = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		m = m>9?m:"0"+m;
		var d = myDate.getDate();        //获取当前日(1-31)
		d = d>9?d:"0"+d;
		var date = y+"-"+m+"-"+d+" 00:00:00";
		console.log(date)
		return date;
	}
	function nowTime(){
		var myDate = new Date();
		var y = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		m = m>9?m:"0"+m;
		var d = myDate.getDate();        //获取当前日(1-31)
		d = d>9?d:"0"+d;
		var h = myDate.getHours();       //获取当前小时数(0-23)
		h = h>9?h:"0"+h;
		var ms = myDate.getMinutes();     //获取当前分钟数(0-59)
		ms = ms>9?ms:"0"+ms;
		var s = myDate.getSeconds();     //获取当前秒数(0-59)
		s = s>9?s:"0"+s;
		var time = y+"-"+m+"-"+d+" "+h+":"+ms+":"+s;
		return time;
	}
	$(".shift-start-time").val(nowDate());
	$(".shift-end-time").val(nowTime());
	//第一个监室号
    $(".treeview").on("click",".node-treeview1",function (){
		$(".treeview ul").html('<li class="list-group-item node-treeview1 node-treeview0">请选择</li>');
		$.ajax({
        	url:"/dormArea/findAll",
        	async:false,
        	success:function (result){
        		console.log(result)
        		for(var i=0;i<result.length;i++){
            		$(".treeview ul").append('<li class="list-group-item node-treeview2" areacode="'+result[i].areacode+'" style="padding-left:30px;">'+result[i].areaname+'</li>')
        		} 
        	}
        });
    	return false;
    });

	var meetingcard1 = "";
    //点击是否刷卡
    $(".iscard").on("click",".card-list",function (){
    	var meetingcard = $(this).find("a").text();
    	if($(this).attr("card")){
    		meetingcard1 = "&swipe="+$(this).attr("card");
    	}else{
    		meetingcard1 = "";
    	}
    	
    	$(".iscard .card-text").text(meetingcard);
    });
    
    $("#btnSearch").on("click",function (){
      btnSearchFn();
    });
    btnSearchFn();
    function btnSearchFn(){
      
    	var shiftjsbh = $(".shift-jsbh").text();

      var shiftjsh1 = $(".treeview .node-treeview1").attr("dormcode");
      if(shiftjsh1){
        shiftjsh1 = "&jshs="+shiftjsh1;
      }else{
        shiftjsh1="";
      }
      var startTime = $(".shift-start-time").val();
      var endTime = $(".shift-end-time").val();
      startTime = startTime?"&startTime="+startTime:"";
      endTime = endTime?"&endTime="+endTime:"";
      var policeName = $(".policeName").val();
      policeName = "&policeName="+policeName;

      var searchUrl = "/pipr/search?jsbh="+shiftjsbh+shiftjsh1+startTime+endTime+meetingcard1+policeName;
      $.ajax({
        url:searchUrl,
        success:function (result){
          $(".searchList tbody").html('');
          for(var i=0;i<result.length;i++){
              var swipeTime = result[i].sksj;
              if(swipeTime!=null){
                var swipeTime = changeTime(swipeTime);
              }
              $(".searchList tbody").append('<tr><td>'+result[i].jsh+'</td><td>'+result[i].mjxm+'</td><td>'+swipeTime+'</td></tr>')
            
          }
        }
      })
      return false;
    }
	//点击页面隐藏下拉菜单
	$("html").on("click",function (){
		if(($(".treeview ul li").length)!=1){
			$(".treeview ul").html('<li class="list-group-item node-treeview1 node-treeview0">请选择</li>');
		}
	});

	function changeTime(time){
		var d = new Date(time);
		var mm = (d.getMonth() + 1)>9?(d.getMonth() + 1):"0"+(d.getMonth() + 1);
		var dd = (d.getDate())>9?(d.getDate()):"0"+(d.getDate());
		var hh = (d.getHours())>9?(d.getHours()):"0"+(d.getHours());
		var ms = (d.getMinutes())>9?(d.getMinutes()):"0"+(d.getMinutes());
		var ss = (d.getSeconds())>9?(d.getSeconds()):"0"+(d.getSeconds());
		var times=d.getFullYear() + '-' + mm + '-' + dd + ' ' + hh + ':' + ms + ':' + ss; 
		return times;
	}

})


</script>
</body>
</html>
